package aspectjlib.aspects;

import org.aspectj.lang.*;
import org.aspectj.lang.annotation.*;

import aspectjlib.enums.CurrentAspect;
import aspectjlib.logging.MasterTracker;
@Aspect
public abstract class AbstractMethodTouchesAspect {

	@Pointcut
	abstract void scope();
	
	@Around("scope() && execution(* *.*(..))")
	public Object simpleAround(ProceedingJoinPoint pjp) throws Throwable {
		String functionId = pjp.toShortString().substring(10, pjp.toShortString().length()-1);
		MasterTracker.getMt(CurrentAspect.METHODTOUCHES).startTimer(functionId);
		Object returnValue = pjp.proceed();
		MasterTracker.getMt(CurrentAspect.METHODTOUCHES).endTimer(functionId, 0L);
		return returnValue;
	}
}